#include "expview.h"
#include "ui_expview.h"
#include<QDebug>
#include<QDate>
#include<QList>
#include<QDesktopWidget>
#include<QtSql/QSqlQuery>
//This class shows different options for viewing expense
ExpView::ExpView(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ExpView)
{
    ui->setupUi(this);
    QRect isize=QApplication::desktop()->availableGeometry(this);
   // ui->listWidget->setGeometry(0,50,(r.width()),(innersize.height()));
    ui->scrollArea->setGeometry(0,0,(isize.width()),(isize.height()));

    int fontSize=10;
    ui->listWidget->setEditFocus(true);
    QAction* backAction = new QAction( tr("Back"), this );
     backAction->setSoftKeyRole( QAction::NegativeSoftKey );
     connect(backAction, SIGNAL(triggered()), this, SLOT(back()));
     addAction( backAction );

     today=new QListWidgetItem(tr("Today"),ui->listWidget,QListWidgetItem::UserType);
     today->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

     monthly=new QListWidgetItem(tr("Monthly"),ui->listWidget,QListWidgetItem::UserType);
     monthly->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

     yearly=new QListWidgetItem(tr("Yearly"),ui->listWidget,QListWidgetItem::UserType);
     yearly->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

     custom=new QListWidgetItem(tr("Custom"),ui->listWidget,QListWidgetItem::UserType);
     custom->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

     cat=new QListWidgetItem(tr("View by category"),ui->listWidget,QListWidgetItem::UserType);
     cat->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

     acc=new QListWidgetItem(tr("View by account"),ui->listWidget,QListWidgetItem::UserType);
     acc->setFont(QFont( "lucida", fontSize, QFont::Normal, FALSE ));

 }

ExpView::~ExpView()
{
    delete ui;
}
void ExpView::back()
{
    (new expense)->show();
}

void ExpView::on_listWidget_itemActivated(QListWidgetItem* item)
{
    if(item==today)
    {
        (new ExpToday)->show();

    }
    else if(item==custom)
    {
        (new ExpCustom)->show();
    }
    else if(item==monthly)
    {
        ExpMonth *e=new ExpMonth(1,1);
        e->setWindowTitle(tr("Select Month"));
        e->show();

    }
    else if(item==yearly)
    {
        ExpMonth *e1=new ExpMonth(2,1);
        e1->setWindowTitle(tr("Select Year"));
        e1->show();
    }
    else if(item==cat)
    {
        ExpByCat *c=new ExpByCat(1);
        //c->setWindowTitle(tr("Select Category"));
        c->show();
    }
    else if(item==acc)
    {
        ExpByCat *a=new ExpByCat(2);
        //a->setWindowTitle(tr("Select Account"));
        a->show();
    }

}


